<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>系统日志</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="css/layui.css" rel="stylesheet">
</head>
<body>
<div>
    <table id="system-log-list"></table>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="btnExport">全部导出</button>
        </div>
    </script>
</div>


<script src="js/layui.js"></script>
<script type="module">
    import systemLog from './js/system-log.js'
    
    layui.use(['layer','table'], function(){
        var $ = layui.$;
        var table = layui.table;
        // 加载系统日志
        var loadSystemLogList = function(isExport){
            systemLog.getSystemLogList($,function(rspData){
                //表格数据渲染
                var insTable = table.render({
                    elem: '#system-log-list'
                    ,toolbar:'#toolbarDemo'
                    ,title:'系统日志'
                    ,width: 700
                    ,height: 600
                    ,cols: [[{ type:"numbers", width:100, title: '序号', sort: true, fixed: 'left'}
                    ,{field:'operateUser', width:200, title: '操作人'}
                    ,{field:'operateType', width:200, title: '操作类型'}
                    ,{field:'createTime', width:160, title: '创建时间'}
                    ]]
                    ,data: rspData.data
                    ,even: true
                    ,page: true //是否显示分页
                    ,limits: [20,50,100]
                    ,limit: 20 //每页默认显示的数量
                });
                if(isExport){
                    table.exportFile(insTable.config.id,rspData.data,'xls');
                }
            })
        }
        loadSystemLogList();
        // 工具栏事件
        table.on('toolbar(system-log-list)', function(obj){
            switch(obj.event){
                case 'btnExport':
                    loadSystemLogList(true);
                break;
            };
        });

    });
</script>
</body>

</html>